<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>homework5</title>
</head>
<body>
    <pre>
        from functools import wraps
        class AuthClass:
            def __init__(self, name, pwd):
                self.name = name
                self.pwd = pwd
            def auth(self):
                if self.name == "python" and self.pwd == "123":
                    return True
                else:
                    return False

        user = AuthClass("torrence", "123")

        def auth_before(f):
            @wraps(f)
            def inner(*args, **kwargs):
                if not user.auth():
                    print("⽤户名或密码错误")
                    return False
                else:
                    return f(*args, **kwargs)
            return inner
            
        @auth_before
        def p1():
            return "用户被装饰函数执行了"
            
        print(p1())
    </pre>
</body>
</html>